package model;

import java.util.ArrayList;

import persistence.Save;


/**
 * Set class
 * @author Adrien Ledeul
 * @version 0.1
 */
public class Set 
{
	private MonitorB monitorB;
	private MonitorA monitorA;
	private FireSensor fireSensor;
	private GasSensor gasSensor;
	private RadiationSensor radiationSensor;
	/**
	 * Constructors
	 * 
	 */
	public Set() 
	{
		monitorA = new MonitorA(this);
		monitorB = new MonitorB(this);
		fireSensor = new FireSensor();
		gasSensor = new GasSensor();
		radiationSensor = new RadiationSensor();
		
		fireSensor.addListener(monitorA);
		radiationSensor.addListener(monitorB);
		gasSensor.addListener(monitorA);
		gasSensor.addListener(monitorB);

	}

	/**
	 * Getters & Setters
	 * 
	 */
	public MonitorB getMonitorB() 
	{
		return monitorB;
	}

	public MonitorA getMonitorA() 
	{
		return monitorA;
	}

	public FireSensor getFireSensor() 
	{
		return fireSensor;
	}

	public GasSensor getGasSensor() 
	{
		return gasSensor;
	}

	public RadiationSensor getRadiationSensor() 
	{
		return radiationSensor;
	}
	
	/**
	 * Serialize received alarms
	 */
	public void serialize() 
	{
		ArrayList<AlarmLog> log = new ArrayList<AlarmLog>();
		
        for (AlarmLog l : monitorA.getLog())
        {
        	log.add(l);
        }
        
        for (AlarmLog l : monitorB.getLog())
        {
        	log.add(l);
        }
        
		Save.serialize(log);
	}


}
